package net.yuyoo.uusession.web;

import javax.servlet.ServletRequest;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletRequestWrapper;
import javax.servlet.http.HttpSession;

/**
 * http request 包装器
 * @author yuyoo (yuyoo4j@163.com)
 * @teme 2010-6-9 下午12:54:32
 */
public class HttpRequestWrapper extends HttpServletRequestWrapper {
	
	private HttpSessionAdapter adapter = null;
	private HttpServletRequest req = null;
	
	public HttpRequestWrapper(HttpSessionAdapter hsa, HttpServletRequest request) {
		
		super(request); 
		this.req = request;
		this.adapter = hsa;
	}
	
	@Override
	public HttpSession getSession() { 
		return adapter;
	}

	@Override
	public HttpSession getSession(boolean create) {
		return create ? adapter.createNewSession() : adapter;
	}


	@Override
	public ServletRequest getRequest() { 
		return this;
	}

	@Override
	public void setRequest(ServletRequest servletrequest) { 
		super.setRequest(servletrequest);
	} 
}
